<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
    <title></title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入bootstrap -->
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
    <!-- 引入JQuery  bootstrap.js-->
    <script src="/js/jquery-3.2.1.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
</head>
<body>
<!-- 顶栏 -->
<jsp:include page="top.jsp"></jsp:include>
<!-- 中间主体 -->
<div class="container" id="content">
    <div class="row">
        <jsp:include page="menu.jsp"></jsp:include>
        <div class="col-md-10">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="row">
                        <h1 style="text-align: center;">编辑角色</h1>
                    </div>
                </div>
                <div class="panel-body">
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th>职务</th>
                            <th>姓名</th>
                            <th>部门职务</th>
                            <th>办公电话</th>

                        </tr>
                        </thead>
                        <tbody >
                        <tr>
                            <td><select id="name">
                                <option value="总指挥">总指挥</option>
                                <option value="副总指挥">副总指挥</option>
                                <option value="安全副矿长">安全副矿长</option>
                                <option value="救援大队">救援大队</option>
                            </select></td>
                            <td><input type="text" id="user_name"></td>
                            <td><select id="position">
                                <option value="矿长">矿长</option>
                                <option value="总长">总长</option>
                                <option value="党委书记">党委书记</option>
                                <option value="安全副矿长">安全副矿长</option>
                                <option value="队长">队长</option>
                                <option value="副队长">副队长</option>
                            </select></td>
                            <td><input type="text" id="officephone"></td>
                        </tr></tbody>
                        <thead>
                        <tr>
                            <th>手机</th>
                            <th>住宅电话</th>
                            <th>其他电话</th>
                            <th>备注</th>

                        </tr>
                        </thead>
                        <tbody><tr>
                            <td><input type="text" id="phonenum"></td>
                            <td><input type="text" id="telephone"></td>
                            <td><input type="text" id="otherphone"></td>
                            <td><input type="text" id="remarks"></td>



                        </tr>

                        </tbody>

                    </table>
                    <div class="form-group" style="text-align: center">
                        <button class="btn btn-default" id="save">提交</button>
                        <button class="btn btn-default" id="qiuxiao">关闭</button>
                    </div>
                </div>

            </div>

        </div>
    </div>
</div>
<div class="container" id="footer">
    <div class="row">
        <div class="col-md-12"></div>
    </div>
</div>
</body>
<script>
    $("#nav li:nth-child(6)").addClass("active")


    $(function () {
        var id=${code.toString()}
        $.ajax({
            url: '/dir/Singlearticle/'+id,
            type: 'get',
            dataType:'json',
            success:function (data) {
                $("#name").attr("value",data.name)
                $("#position").attr("value",data.position)
                $("#user_name").attr("value",data.user_name)
               $("#phonenum").attr("value",data.phonenum)
                $("#telephone").attr("value",data.telephone)
                $("#otherphone").attr("value",data.otherphone)
                $("#officephone").attr("value",data.officephone)
                $("#remarks").attr("value",data.remarks)
            }

        })

        $("#save").click(function () {
            var name=$("#name").val()
            var position=$("#position").val()
            var user_name=$("#user_name").val()
            var phonenum=$("#phonenum").val()
            var telephone=$("#telephone").val()
            var otherphone=$("#otherphone").val()
            var officephone=$("#officephone").val()
            var remarks=$("#remarks").val()


            var searchMap = {
                "id":id,
                "name": name,
                "position": position,
                "user_name": user_name,
                "phonenum": phonenum,
                "telephone": telephone,
                "otherphone": otherphone,
                "remarks": remarks,
                "officephone": officephone
            };

              $.ajax({
                url: '/dir/editRescueBrigade',
                type: 'put',
                dataType:'json',
                data: JSON.stringify(searchMap),
                contentType: "application/json",
                success: function () {
                    alert("保存成功")
                    window.location.href="/admin/addCommandPost";

                },
                error: function () {
                    alert("保存失败")
                }
            })


        })
        $("#qiuxiao").click(function () {
            window.location.href="systemSettings";
        })
    })



</script>
</html>